<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <script>
        // 某一个需求需要发送2次请求，就使用promise进行包装
        Promise.all([
            new Promise((resolve, reject) => {
                setTimeout(() => {
                    resolve({name:'yzh', age:22})
                }, 2000);
            }),
            new Promise((resolve, reject) => {
                setTimeout(() => {
                    resolve({name:'hsz', age:18})
                }, 1000);
            })
        ]).then(results => {
            console.log(results);
            console.log(results[0]);
            console.log(results[1]);
        })
    </script>
</body>
</html>